package com.zhz.project.main;

import java.util.List;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.zhz.project.dal.daointerface.BookDAO;
import com.zhz.project.dal.dataobject.Book;

public class ModifyOpenjgateURL {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(
            new String[] { "ibatis-spring.xml" });

        BookDAO bookDAO = (BookDAO) appContext.getBean("bookDAO");
        List<Book> list = bookDAO.selectAllOpenJgateBooks();
        for (Book book : list) {
            String url = book.getUrl();
            url = url.replace("Articlelist", "Browse/Articlelist");
            url = url.replace("asp", "aspx");
            url = url.replace("Source=1&", "");
            book.setUrl(url);
            System.out.println(book.getUrl());
            bookDAO.updateBook(book);
        }
    }
}
